/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.gob.pnp.model;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import pe.gob.pnp.beans.AccionTramiteBean;
import pe.gob.pnp.factories.ConnectionPool;

/**
 *
 * @author Greco
 */
public class GestionAccionTramite {

    public List<AccionTramiteBean> obtenerAccionTramite() throws SQLException {
        List<AccionTramiteBean> lstAccionTramite = new ArrayList<AccionTramiteBean>();
        Connection conn = null;
        try {
            conn = ConnectionPool.obtenerConexion();
            String sql = "SELECT NACTR_IDENTIFICADOR,CACTR_DESCRIPCION";
            sql += " FROM DIRPEN.SISMA_ACCIONTRAMITE";
            sql += " WHERE BACTR_ESTADO=1";
            sql += " AND BACTR_ELIMINADO=0";
            sql += " ORDER BY CACTR_DESCRIPCION";
            PreparedStatement ps = conn.prepareStatement(sql);
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                AccionTramiteBean obj = new AccionTramiteBean();
                obj.setNactrIdentificador(rs.getInt("NACTR_IDENTIFICADOR"));
                obj.setCactrDescripcion(rs.getString("CACTR_DESCRIPCION"));
                lstAccionTramite.add(obj);
            }
            rs.close();
            ps.close();
        } catch (Exception err) {
            err.printStackTrace();
        } finally {
            ConnectionPool.liberarConexion(conn);
        }
        return lstAccionTramite;
    }
}
